package com.huike.springboot1.demos.interceptor.config;

import com.huike.springboot1.demos.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private MyInterceptor myInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/**") // 拦截所有
//                通行路径
                .excludePathPatterns(
                        "/productList1",  //前台页面
                        "/searchProduct1", //前台搜索
                        "/toLogin",       // 登录页面
                        "/login",       // 登录判断
                        "/toRegister",       // 注册页面
                        "/register",       // 注册判断
                        "/css/**", "/js/**", "/images/**" // 静态资源
                );
    }
}
